this._closedId = this._channel.connect('invalidated', Lang.bind(this, this._channelClosed));
this._notification = new ChatNotification(this);
+ this._notification.connect('clicked', Lang.bind(this, this.open));
this._notification.setUrgency(MessageTray.Urgency.HIGH);
this._notifyTimeoutId = 0;
this._notification.update(this._notification.title, null, { customContent: true });
},
- open: function(notification) {
- if (this._client.is_handling_channel(this._channel)) {
- // We are handling the channel, try to pass it to Empathy
- this._client.delegate_channels_async([this._channel],
- global.get_current_time(),
- 'org.freedesktop.Telepathy.Client.Empathy.Chat', null);
- }
- else {
- // We are not the handler, just ask to present the channel
- let dbus = Tp.DBusDaemon.dup();
- let cd = Tp.ChannelDispatcher.new(dbus);
-
- cd.present_channel_async(this._channel, global.get_current_time(), null);
- }
+ open: function() {
+ if (this._client.is_handling_channel(this._channel)) {
+ // We are handling the channel, try to pass it to Empathy
+ this._client.delegate_channels_async([this._channel],
+ global.get_current_time(),
+ 'org.freedesktop.Telepathy.Client.Empathy.Chat', null);
+ } else {
+ // We are not the handler, just ask to present the channel
+ let dbus = Tp.DBusDaemon.dup();
+ let cd = Tp.ChannelDispatcher.new(dbus);
+
+ cd.present_channel_async(this._channel, global.get_current_time(), null);
+ }
},
_getLogMessages: function() {
if (this.notifications.indexOf(notification) >= 0)
return;
- notification.connect('clicked', Lang.bind(this, this.open));
notification.connect('destroy', Lang.bind(this, this._onNotificationDestroy));
-
this.notifications.push(notification);
this.emit('notification-added', notification);
soundName: hints['sound-name'] });
notification.setImage(image);
+ let hasDefaultAction = false;
+
if (actions.length) {
let useActionIcons = (hints['action-icons'] == true);
for (let i = 0; i < actions.length - 1; i += 2) {
let [actionId, label] = [actions[i], actions[i+1]];
if (actionId == 'default') {
- notification.connect('clicked', Lang.bind(this, function() {
- this._emitActionInvoked(ndata.id, "default");
- }));
+ hasDefaultAction = true;
} else {
notification.addButton(this._makeButton(id, label, useActionIcons), Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, actionId);
}
}
}
+
+ if (hasDefaultAction) {
+ notification.connect('clicked', Lang.bind(this, function() {
+ this._emitActionInvoked(ndata.id, 'default');
+ }));
+ } else {
+ notification.connect('clicked', Lang.bind(this, function() {
+ source.open();
+ }));
+ }
+
switch (hints.urgency) {
case Urgency.LOW:
notification.setUrgency(MessageTray.Urgency.LOW);
let [title, banner] = this._getTitleAndBanner(app, window);
let notification = new MessageTray.Notification(source, title, banner);
+ notification.connect('clicked', function() {
+ source.open();
+ });
notification.setForFeedback(true);
source.notify(notification);
return this._app.create_icon_texture(size);
},
- open : function(notification) {
+ open: function() {
Main.activateWindow(this._window);
this.destroy();
}